﻿/**
 * Created by Administrator on 2017/8/7.
 *私客转公客
 */
define(['api'],function (api) {
    var ShiftCustomerToDept = {
        name: 'ShiftCustomerToDept',
        template: ''
        + '<Modal title="放入公客池"'
        + '       v-model="showShiftCustomerToDept"'
        + '       width="360"'
        + '       ok-text="确认"'
        + '       v-on:on-cancel="closeShift"'
        + '       v-on:on-ok="shiftCustomerToDept"'
        + '       v-bind:closable="false"'
        + '       v-bind:mask-closable="false"'
        + '       class-name="addPublicWrap  vertical-center-modal shiftCustomerToDept">'
        + '    <div class="modal-content" v-cloak>'
        + '        <ul class="pri-ul">'
        + '            <h3 class="warning">确认将选中客户放入公客池吗？</h3>'
        + '        </ul>'
        + '    </div>'
        + '</Modal>',
        data: function () {
            return {
                customerList: [],
                showShiftCustomerToDept: false
            }
        },
        mounted: function () {
            var thisSift = this;
            //监听showShiftCustomerToDept
            window.bus.$on("showShiftCustomerToDept", function (data) {
                thisSift.customerList = data;
                thisSift.showShiftCustomerToDept = true;
                //触发deleteFocus
                window.bus.$emit("deleteFocus");
            });
        },
        methods: {
            closeShift: function () {
            },
            shiftCustomerToDept: function () {
                var thisShift = this;
                api.Post_Shift_Customer_ToDept({customerList:thisShift.customerList})
                    .done(function (data) {
                        if (data.IsSuccess) {
                            thisShift.$Message.success('转入成功');
                            //触发shiftCustomerToDeptSuccess
                            window.bus.$emit("shiftCustomerToDeptSuccess");
                        } else {
                            thisShift.$Message.error(data.ErrMsg);
                        }
                    })
                    .fail(function () {
                        thisShift.$Message.success('转入失败');
                    });
            }
        },
    };
    return ShiftCustomerToDept;
});
